#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "Observation.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class NamedElement;

/// <summary>
/// TimeObservation
/// A TimeObservation is a reference to a time instant during an execution. It
/// points out the NamedElement in the model to observe and whether the observation
/// is when this NamedElement is entered or when it is exited.
/// </summary>
class UMLMODEL_EXPORT TimeObservation : public Observation {

public: // Constructors and destructors
    explicit TimeObservation(const QString& umlType="uml::TimeObservation");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// event getter
    /// The TimeObservation is determined by the entering or exiting of the event
    /// Element during execution.
    /// </summary>
    shared_ptr<NamedElement> event() const;

    /// <summary>
    /// event setter
    /// The TimeObservation is determined by the entering or exiting of the event
    /// Element during execution.
    /// </summary>
    void setEvent(shared_ptr<NamedElement> value);

    /// <summary>
    /// firstEvent getter
    /// The value of firstEvent is related to the event. If firstEvent is true, then the
    /// corresponding observation event is the first time instant the execution enters
    /// the event Element. If firstEvent is false, then the corresponding observation
    /// event is the time instant the execution exits the event Element.
    /// </summary>
    bool firstEvent() const;

    /// <summary>
    /// firstEvent setter
    /// The value of firstEvent is related to the event. If firstEvent is true, then the
    /// corresponding observation event is the first time instant the execution enters
    /// the event Element. If firstEvent is false, then the corresponding observation
    /// event is the time instant the execution exits the event Element.
    /// </summary>
    void setFirstEvent(bool value);

private: // Fields
    /// <summary>
    /// event
    /// The TimeObservation is determined by the entering or exiting of the event
    /// Element during execution.
    /// </summary>
    shared_ptr<NamedElement> event_;

    /// <summary>
    /// firstEvent
    /// The value of firstEvent is related to the event. If firstEvent is true, then the
    /// corresponding observation event is the first time instant the execution enters
    /// the event Element. If firstEvent is false, then the corresponding observation
    /// event is the time instant the execution exits the event Element.
    /// </summary>
    const static bool firstEvent_default_;
    bool firstEvent_= firstEvent_default_;

};

} // namespace uml
